namespace Sample.Domain
{
    public static class EqualityHelper
    {
        /// <summary>
        /// Extension method for any kind of typed object to determine
        /// if it is equal to another object of any type
        /// </summary>
        /// <typeparam name="T">Extension method type</typeparam>
        /// <param name="source">Specific object to test</param>
        /// <param name="obj">Object to compare to</param>
        /// <returns></returns>
        public static bool IsEqual<T>(this T source, object obj) where T : class
        {
            var target = obj as T;
            
            if (obj != null)
            {
                return target != null && target.GetHashCode().Equals(source.GetHashCode());
            }

            return false;
        }
    }
}